<?php

	include_once '../com/mss/model/Stock.php';
	include '../com/mss/common/Connection.php';
	
	class StockAccessor {
	
	    public function save(Stock $stock) {
	        $connection = Connection::open();
	
	        $drug_id = $stock->getDrugID();
	        $monastery_id = $stock->getMonasteryID();
	        $exp_date = $stock->getExpDate();
	        $stocked_quantity = $stock->getStockedQuantity();
	        $stocked_date = $stock->getStockedDate();
	        $user_id = $stock->getUserID();
	
	        $query = "INSERT INTO SS_STOCK (DRUG_ID, MONASTERY_ID, EXPIRY_DATE, STOCKED_QUANTITY, STOCKED_DATE, USER_ID) 
	        VALUES ('$drug_id', '$monastery_id', '$exp_date', '$stocked_quantity', '$stocked_date', '$user_id')";
	
	        mysql_query($query, $connection) or die("could not save data");
	
	        Connection::close($connection);
	    }
	    
	    public function select($drug_id, $monastery_id, $exp_date) {
	    	
	    }
	
	    public function update(Stock $stock) {
	        $connection = Connection::open();
	
	        $stocked_quantity = $stock->getStockedQuantity();
	        $stocked_date = $stock->getStockedDate();
	        $user_id = $stock->getUserID();
	
	        $query = "UPDATE SS_STOCK (STOCKED_QUANTITY, STOCKED_DATE, USER_ID) 
	        VALUES ('$stocked_quantity', '$stocked_date', '$user_id')";
	
	        mysql_query($query, $connection) or die("could not save data");
	
	        Connection::close($connection);
	    }
	
	}

?>